/*
 * @Description: 零部件接口
 * @Author: ppzhang
 * @Date: 2021-05-18
 * @LastEditTime: 2021-09-28 13:16:09
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPartsPillar/listPage') : '/jcwBasic/jcwPartsPillar/listPage',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPartsPillar/parts/getById`) : `/jcwBasic/jcwPartsPillar/parts/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwParts/saveOrUpdateData') : '/jcwBasic/jcwParts/saveOrUpdateData',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwParts/${params.id}`) : `/jcwBasic/jcwParts/${params.id}`,
    method: 'DELETE'
  })
}

// 查询列表信息（零部件组件使用）
export function getPartListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPartsPillar/pageData') : '/jcwBasic/jcwPartsPillar/pageData',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息（零部件组件使用）
export function getPartInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPartsPillar/getById`) : `/jcwBasic/jcwPartsPillar/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息（零部件组件使用）
export function addOrEditPartData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPartsPillar/saveOrUpdateData') : '/jcwBasic/jcwPartsPillar/saveOrUpdateData',
    method: 'POST',
    data: params
  })
}

// 保存绑定装配图
export function bindPartData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPartsPillar/updateAssemblyId') : '/jcwBasic/jcwPartsPillar/updateAssemblyId',
    method: 'POST',
    data: params
  })
}

// 模板导入
export function uploadPart(query) {
  return request({
    url: `/basic/part/upload`,
    method: 'POST',
    data: query
  })
}
